/**
 * ...
 * @author Hatshepsout
 */

function ImageResizer(){}


ImageResizer.MAX_IMAGE_WIDTH =  800;

ImageResizer.resize = function( img )
{
	var maxWidth = ImageResizer.MAX_IMAGE_WIDTH;
	var canvas = document.createElement("canvas");
	var context = canvas.getContext("2d");
	var ratio = ( img.width > maxWidth ) ? img.width / maxWidth : 1 ;
	var width = img.width / ratio;
	var height = img.height / ratio;
	var dataURL = "";
	
	canvas.width = width;
	canvas.height = height;
	
	context.save();
	context.scale( 1/ratio, 1/ratio );
	context.drawImage(img,0,0);
	context.restore();
	
	dataURL = canvas.toDataURL();
	return dataURL;
};